Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adopting Hammercast for More Expressive Assertions in Tests
Motivation and Logic: In this PR, I have introduced Hammercast into our test suite to improve the readability and expressiveness of our assertions. Hammercast allows us to make assertions in a more declarative style, which not only enhances the clarity of the tests but also provides better error messages when assertions fail.
For example, instead of using traditional assertions like
assert len(responses.calls) == 1
, we now useassert_that(responses.calls, has_length(1))
, which clearly communicates the intention of the test and makes it easier to understand the expected state.The primary motivation behind this change is to improve the developer experience when reading, writing, and debugging tests. Hammercast's expressive matchers (like
has_length
,is_
,equal_to
, and others) provide a more readable way to express conditions, aligning with the Pythonic philosophy of clear and concise code.Scope and Changes: The changes in this PR apply Hammercast matchers across all test files. As a result, there are many lines of code affected, but it's important to note that the test logic itself remains unchanged. The tests continue to cover the same functionality and are expected to behave in the same way as before.
Plan: Although this PR involves a substantial number of line changes, the changes are limited to updating assertions and do not alter the test logic itself. Here’s my suggestion on how to approach reviewing this PR:
Review Focus: focus on the assertion changes made with Hammercast. These are mostly stylistic changes and should not affect the underlying test logic.
Further Iterations: If any tests require additional changes to better leverage Hammercast, I would love to address those in future contributions.
Personal Note: I want to take a moment to express how much I appreciate the work done on this project. I’ve been using it for a while and think it’s a fantastic tool!. I’m excited to contribute to its growth